package com.lagou.edu.controller;

import com.lagou.edu.service.ICodeService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author stevejson
 */
@RestController
@RequestMapping("/code")
public class CodeController {
    @Resource
    private ICodeService codeService;

    @RequestMapping(value = "/create/{email}", method = RequestMethod.POST)
    public Boolean createCode(@PathVariable String email){
        return codeService.createCode(email);
    }

    @RequestMapping(value = "/validate/{email}/{code}", method = RequestMethod.GET)
    public Integer validateCode(@PathVariable String email, @PathVariable String code){
        return codeService.validateCode(email,code);
    }
}
